import "package:flutter/material.dart";
import "./routers/routers.dart";
import 'package:flutter_localizations/flutter_localizations.dart';

// 应用入口
void main() {
  //1、配置路由
  //应用类
  runApp(MaterialApp(
    theme: ThemeData(
      colorScheme:const ColorScheme.light(background: Color.fromARGB(255, 244, 244, 244)),
    ),
    debugShowCheckedModeBanner: false, //关闭debug图标
    // 首页-生成一个页面布局
    // home: const HomePage(),//使用命名式路由后不需要配置home
    // 命名式路由导航，使用命名式路由导航后，如果其他页面互相调整，则不需要再引入页面，可直接使用命名式路由导航
    // routes: {
    //   "/": (context) => const HomePage(), //“/”表示首页地址
    //   "/search": (context) => const SearchPage(),
    //   "/form": (context) => const FormPage(),
    //   "/params": (context) => const ParamsPage()
    // },
    initialRoute: "/", //初始路由
    // 2、配置 onGenerateRoute 固定写法，相当于路由守卫
    onGenerateRoute: onGenerateRoute,
    supportedLocales: const [
      Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans'),
      Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'),
      Locale.fromSubtags(
        languageCode: 'en',
      ),
    ],
    localizationsDelegates: const [
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
    ],
  ));
}
